﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Text;
namespace Web1
{
    public partial class WebForm3 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Label1.Text = DateTime.Now.ToString();
        }
       

        protected void LinkButton1_Click(object sender, EventArgs e)
        {

        }

        protected void LinkButton3_Click(object sender, EventArgs e)
        {

        }

        protected void LinkButton2_Click(object sender, EventArgs e)
        {

        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            this.lblInfo.Text = "";
            this.txtNo.Text = "";
            this.txtGender.Text = "";
            this.txtCol.Text = "";
            this.txtClass.Text = "";
            this.txtName.Text = "";
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            StringBuilder sb = new StringBuilder(1024);
            sb.Append("INSERT INTO Student ");
            sb.Append("                (No, Name, Gender, College, Class) ");
            sb.Append("VALUES   (@No,@Name,@Gender,@College,@Class) ");
            SqlParameter[] pms = new SqlParameter[5];
            pms[0] = new SqlParameter("@No", this.txtNo.Text);
            pms[1] = new SqlParameter("@Name", this.txtName.Text);
            pms[2] = new SqlParameter("@Gender", this.txtGender.Text);
            pms[3] = new SqlParameter("@College", this.txtCol.Text);
            pms[4] = new SqlParameter("@Class", this.txtClass.Text);
            int intResult = SqlHelper.ExecuteNonQuery(sb.ToString(), pms);
            this.lblInfo.Text = (intResult < 1) ? "新增失败！" : "新增了" + intResult.ToString() + "条记录！";
        }

        protected void LinkButton4_Click(object sender, EventArgs e)
        {

        }

        

        protected void Button4_Click(object sender, EventArgs e)
        {

        }
    }
}